package pkg

import (
	"encoding/json"
	"github.com/Baidu-AIP/golang-sdk/aip/censor"
	"weekly-exam/config"
)

type Chesk struct {
	ConclusionType uint `json:"conclusionType" form:"conclusionType"`
}

func Check(message string) bool {
	//通过access_toke
	data := config.ConappfigData.Baidu
	client := censor.NewClient(data.Ak, data.Sk)
	//使用百度云API认证机制
	res := client.TextCensor(message)
	var chesk Chesk
	json.Unmarshal([]byte(res), &chesk)
	if chesk.ConclusionType == 1 {
		return true
	}
	return false

}
